package objects;

import java.util.ArrayList;

public class PlayerInfo {
	
	public int gold = 10;
	public int stone = 10;
	public int wood = 10;
	public int iron = 10;
	
	public int points = 0;
	
	public ArrayList<BuildingCard> buildingCards = new ArrayList<BuildingCard>();
	public ArrayList<PalaceCard> palaceCards = new ArrayList<PalaceCard>();
	public ArrayList<SettlementCard> settlementCards = new ArrayList<SettlementCard>();
	public ArrayList<SoldierCard> soldierCards = new ArrayList<SoldierCard>();
	
	public static final int victoryLine = 30;
	
	public PlayerInfo(){
		
	}
		
	public PlayerInfo(int gold, int stone, int wood, int iron){
		this.gold = gold;
		this.stone = stone;
		this.wood = wood;
		this.iron = iron;
	}
	
	public boolean checkVictory(){
		if(points >= victoryLine){
			return true;
		} else {
			return false;
		}
	}
	
	public void destroySoliers(int hpLoss) {
		int hpToLose = hpLoss;
		while(hpToLose > 0){
			int attackedCard = (int) Math.round(Math.random()*soldierCards.size());
			if(hpToLose >= soldierCards.get(attackedCard).lifePoints){
				hpToLose -= soldierCards.get(attackedCard).lifePoints;
				soldierCards.remove(attackedCard);
			} else {
				hpToLose = 0;
			}
		}
	}
	
	/////////
	//Earn & Spend
	/////////
	
	public void earn(int gold, int stone, int wood, int iron){
		this.gold += gold;
		this.stone += stone;
		this.wood += wood;
		this.iron += iron;
	}
	
	public void spend(int gold, int stone, int wood, int iron){
		this.gold -= gold;
		this.stone -= stone;
		this.wood -= wood;
		this.iron -= iron;
	}
}